package com.lzj;
// 定义一个类来表示购物车和计算总价
public class ShoppingCart {
    // 水果重量
    private int appleWeight;
    private int strawberryWeight;
    private int mangoWeight;
    // 草莓折扣
    private double STRAWBERRY_DISCOUNT = 0.8;
    // 折扣阈值
    private int DISCOUNT_THRESHOLD = 100;
    // 折扣优惠值
    private int DISCOUNT_AMOUNT = 10;

    public ShoppingCart(int appleWeight, int strawberryWeight, int mangoWeight) {
        this.appleWeight = appleWeight;
        this.strawberryWeight = strawberryWeight;
        this.mangoWeight = mangoWeight;
    }

    // 计算顾客A的总价
    public double calculateTotalForCustomerA(Fruit apple, Fruit strawberry) {
        return apple.getTotalPrice() * appleWeight + strawberry.getTotalPrice() * strawberryWeight;
    }

    // 计算顾客B的总价
    public double calculateTotalForCustomerB(Fruit apple, Fruit strawberry, Fruit mango) {
        return apple.getTotalPrice() * appleWeight + strawberry.getTotalPrice() * strawberryWeight + mango.getTotalPrice() * mangoWeight;
    }

    // 计算顾客C的总价（草莓打8折）
    public double calculateTotalForCustomerC(Fruit apple, Fruit strawberry, Fruit mango) {
        return apple.getTotalPrice() * appleWeight + (strawberry.getTotalPrice() * STRAWBERRY_DISCOUNT) * strawberryWeight + mango.getTotalPrice() * mangoWeight;
    }

    // 计算顾客D的总价（满100减10）
    public double calculateTotalForCustomerD(Fruit apple, Fruit strawberry, Fruit mango) {
        double total = apple.getTotalPrice() * appleWeight + (strawberry.getTotalPrice() * STRAWBERRY_DISCOUNT) * strawberryWeight + mango.getTotalPrice() * mangoWeight;
        return total >= DISCOUNT_THRESHOLD ? total - DISCOUNT_AMOUNT : total;
    }
}
